<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div>
  <a [routerLink]="['..']" class="gv-back-link"><small><< Back to resources</small></a>
  <div fxLayout="row" style="margin-top: 10px;">
    <form fxLayout="column" fxFlex="70">
      <div class="gv-form-section">
        <div class="gv-form-section-title">
          <h5>Resource</h5>
          <mat-divider></mat-divider>
        </div>
        <div>
          <mat-form-field *ngIf="resource.name" appearance="outline" floatLabel="always">
            <mat-label>Name</mat-label>
            <input matInput placeholder="Name" disabled [value]="resource.name">
            <mat-hint>Resource's name</mat-hint>
          </mat-form-field>
          <mat-form-field *ngIf="resource.userDisplayName" appearance="outline" floatLabel="always">
            <mat-label>Owner</mat-label>
            <input matInput placeholder="Owner" disabled [value]="resource.userDisplayName">
            <mat-hint>Resource's owner</mat-hint>
          </mat-form-field>
          <mat-form-field *ngIf="resource.type" appearance="outline" floatLabel="always">
            <mat-label>Type</mat-label>
            <input matInput placeholder="Type" disabled [value]="resource.type">
            <mat-hint>Resource's type</mat-hint>
          </mat-form-field>
          <mat-form-field *ngIf="resource.description" appearance="outline" floatLabel="always">
            <mat-label>Description</mat-label>
            <input matInput placeholder="Description" disabled [value]="resource.description">
            <mat-hint>Resource's description</mat-hint>
          </mat-form-field>
          <mat-form-field *ngIf="resource.iconUri" appearance="outline" floatLabel="always">
            <mat-label>Icon</mat-label>
            <input matInput placeholder="Icon" disabled [value]="resource.iconUri">
            <mat-hint>Resource's icon</mat-hint>
          </mat-form-field>
          <mat-form-field *ngIf="resource.resourceScopes" appearance="outline" floatLabel="always">
            <mat-label>Scopes</mat-label>
            <mat-chip-list aria-label="Resource scopes" disabled>
              <mat-chip *ngFor="let scope of resource.resourceScopes">
                {{scope}}
              </mat-chip>
            </mat-chip-list>
            <mat-hint>Resource's scopes</mat-hint>
          </mat-form-field>
        </div>
      </div>
      <div class="gv-form-section">
        <div class="gv-form-section-title">
          <h5>Policies</h5>
          <small>Authorization grant rules, which the authorization server executes in the process of issuing access tokens.</small>
          <mat-divider></mat-divider>
        </div>
        <div>
          <ngx-datatable class="material"
                         [columnMode]="'flex'"
                         [headerHeight]="40"
                         [footerHeight]="40"
                         [rowHeight]="50"
                         [rows]='policies'>
            <ngx-datatable-column name="Policy" [flexGrow]="4" [cellClass]="'policy-name-cell'">
              <ng-template let-row="row" ngx-datatable-cell-template>
                <div class="policy-header" fxLayout="row">
                  <div class="policy-icon">
                    <mat-icon>policy</mat-icon>
                  </div>
                  <div class="policy-information" fxLayout="column">
                    <h3>{{row.name}}</h3>
                    <small>{{row.description}}</small>
                  </div>
                </div>
              </ng-template>
            </ngx-datatable-column>
            <ngx-datatable-column name="" [flexGrow]="1">
              <ng-template let-row="row" ngx-datatable-cell-template>
                <div fxLayout="row" class="gv-table-cell-actions">
                  <a mat-icon-button [routerLink]="['policies', row.id]" *hasPermission="['application_resource_read']"><mat-icon matTooltip="Settings">settings</mat-icon></a>
                </div>
              </ng-template>
            </ngx-datatable-column>
          </ngx-datatable>
        </div>
      </div>
    </form>
    <div class="gv-page-description" fxFlex>
      <h3>Resource details</h3>
      <div class="gv-page-description-content">
        <p>View the detailed properties of the resource.</p>
      </div>
    </div>
  </div>
</div>
